//
//  CommendAcCell.m
//  Shengzhuli
//
//  Created by FXGuo on 2018/3/14.
//  Copyright © 2018年 kamangkeji. All rights reserved.
//

#import "CommendAcCell.h"
#import <UIImageView+WebCache.h>
#import "NSDate+Extension.h"

@interface CommendAcCell()

@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UILabel *nameLab;
@property (weak, nonatomic) IBOutlet UILabel *timeLab;
@property (weak, nonatomic) IBOutlet UILabel *moneyLab;
@property (weak, nonatomic) IBOutlet UILabel *countLab;

@end

@implementation CommendAcCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setModel:(HomeCommendDetailModel *)model
{
    _model = model;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.thumbnail] placeholderImage:GetImage(@"default_goods_image")];
    self.nameLab.text = model.title;
    self.timeLab.text = [NSString stringWithFormat:@"举办时间:%@",[NSDate spToDateString:model.startDate]];
    
    NSInteger count = [NSString stringWithFormat:@"%zd",model.applyCount].length;
    NSString *str = [NSString stringWithFormat:@"%zd人已报名",model.applyCount];
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:str];
    [attrStr addAttributes:@{NSFontAttributeName:Font(11),NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#3285ff"]} range:NSMakeRange(0, count)];
    [attrStr addAttributes:@{NSFontAttributeName:Font(11),NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#888888"]} range:NSMakeRange(count, str.length-count)];
    self.countLab.attributedText = attrStr;
}
- (IBAction)reportClick:(UIButton *)btn
{
    if (self.reportClick) {
        self.reportClick(self.model);
    }
}


@end
